<?php echo $this->render('header.phtml'); ?>
<?php echo $this->render('menu.phtml'); ?>
<div id="content">
    <div id="icon-page" class="icon32"><br/></div><h2>添加页面</h2>
    <form action="/backend/add/page/" method="post" onsubmit="return submitForm();">
        <div id="tabs-1" class="editor-area">
            <div class="titlebox">
                <h3><span>标题</span></h3>
                <input type="text" class="title" id="page_title" name="page_title" autocomplete="off" value="" tabindex="1" size="30" />
            </div>
            <div>
                <h3><span>内容</span></h3>
                <textarea id="page_content" name="page_content" cols="100" rows="8"></textarea>
            </div>
            <div id="message-box" class="ui-state-error ui-corner-all" style="display: none;padding: 12px;">
                <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: 12px;"></span>
                    <strong>警告:</strong> <span id="error-message"></span>
                </p>
            </div>
            <div>
                <input id="publish" type="submit" value="发布" name="publish"/>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="/public/editor/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/public/editor/ckfinder/ckfinder.js"></script>
<script type="text/javascript">
    function submitForm(){
        if ($("#page_title").val() == ''){
            $("#message-box").show();
            $("#error-message").empty();
            $("#error-message").append("请输入页面标题!");
            return false;
        } else if ($("#page_content").val() == '') {
            $("#message-box").show();
            $("#error-message").empty();
            $("#error-message").append("请输入页面内容!");
            return false;
        } else{
            return true;
        }
    }

    CKEDITOR.replace('page_content',
    {
        toolbar :
            [
            ['Cut','Copy','Paste','PasteText','PasteFromWord'],
            ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
            ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
            '/',
            ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
            ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
            ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
            ['Link','Unlink','Anchor'],
            ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
            '/',
            ['Styles','Format','Font','FontSize'],
            ['TextColor','BGColor'],
            ['Maximize', 'ShowBlocks','Source']
        ],
        filebrowserBrowseUrl : '/public/editor/ckfinder/ckfinder.html',
        filebrowserImageBrowseUrl : '/public/editor/ckfinder/ckfinder.html?Type=Images',
        filebrowserFlashBrowseUrl : '/public/editor/ckfinder/ckfinder.html?Type=Flash',
        filebrowserUploadUrl : '/public/editor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
        filebrowserImageUploadUrl : '/public/editor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
        filebrowserFlashUploadUrl : '/public/editor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
    });
</script>
<?php echo $this->render('footer.phtml'); ?>